home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / OOP.SWG / 0003_DELAYDLG.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  33 lines

  1. {
  2. ▒Hello.  I was toying around With TVision, trying to make derive an Object fr
  3. ▒TDialog which would be a simple 'Delay box' (i.e. a message would display, t
  4. ▒the box would cmOK itself after two seconds).  I tried a simple Delay() comm
  5. ▒in HandleEvent, which seemed to work fine, but when I held down the mouse bu
  6. ▒on the menu, it locked up and sometimes my memory manager woudl report crazy
  7. ▒error messages.  Can anyone offer a suggestion on how to do this safely?  Th
  8. ▒are certain situations when clicking an 'OK' button is just a hassle.  Thank
  9.  
  10. Try trapping the mouse events in the HandleEvent method of the dialog
  11. box.
  12. }
  13.  
  14. Type
  15.   tDelayDialog = Object(tDialog)
  16.     Procedure HandleEvent(Var Event : tEvent); VIRTUAL;
  17.   end;
  18.  
  19. Procedure tDelayDialog.HandleEvent(Var Event : tEvent);
  20. Const
  21.   cDelay = 2000;
  22. begin
  23.   if Event.What and evMouse <> 0 then (* This filters out mouse   *)
  24.                                       (* events before they reach *)
  25.                                       (* the parent               *)
  26.   ELSE
  27.   begin
  28.     Delay(cDelay);
  29.     Event.Command := cmOK;          (* Set up the command       *)
  30.     INHERITED HandleEvent(Event);   (* Let the parent handle it *)
  31.   end;
  32. end;
  33.